<?php
class Adm_type_model extends CI_Model {


	public function __construct(){
		parent::__construct();
		$this->db = $this->load->database('default',true);
	}

	/**
	 *
	 *
		* @name query_device_name
		* @date 2013-1-11
		* @author eifel
		* @param string 硬件类别编号
		* @return string 硬件类别名称
		* @version 1.0
		* @description 根据硬件类别的编号来查询硬件名称
	 */
	public function query_device_name($device_class) {
		$device_class	=	$this->db->escape($device_class);
		$sql 			=	"select TYPE_NAME from ADM_TYPE where TYPE_ID =$device_class and BE_DEVICE_CLASS =1 limit 1";
		$query			=	$this->db->query($sql);
		if ($query->num_rows()>0) {
			$row 	=$query->row_array();
			return $row['TYPE_NAME'];
		}
	}

	/**
	 *
	 *
		* @name query_device_type_list
		* @date 2013-1-22
		* @author eifel
		* @param
		* @return array 硬件类别列表
		* @version 1.0
		* @description 查询硬件的类别列表
	 */
	public function query_device_type_list() {
		$sql 			=	"select TYPE_NAME,TYPE_ID 
							from ADM_TYPE inner join ADM_TYPE_TARGET on ADM_TYPE.TARGET_ID =ADM_TYPE_TARGET.TARGET_ID
							
							where TARGET_KEY ='hard_type' and BE_DEVICE_CLASS =1 ";
		$query			=	$this->db->query($sql);
		if ($query->num_rows()>0) {
			return $query->result_array();
		}
	}
}